TextSave = "multi user chat example by Jon Cromer"
EndProperty
EndProperty
End
Begin VB.CommandButton Command1
Caption = "Connect"
Height = 315
Left = 5880
TabIndex = 10
Top = 3480
Width = 1335
End
Begin VB.TextBox Text3
Height = 285
Left = 5640
TabIndex = 9
Top = 3000
Width = 1815
End
Begin VB.TextBox Text4
Height = 285
Left = 5640
TabIndex = 7
Text = "127.0.0.1"
Top = 2400
Width = 1815
End
Begin VB.Timer Timer1
Interval = 1
Left = 5640
Top = 3840
End
Begin VB.ListBox List1
Height = 1650
Left = 5640
TabIndex = 5
Top = 240
Width = 1815
End
Begin VB.TextBox Text2
BeginProperty Font
Name = "Arial"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 285
Left = 0
TabIndex = 2
Top = 3840
Width = 5535
End
Begin RichTextLib.RichTextBox Text1
Height = 3735
Left = 0
TabIndex = 1
Top = 0
Width = 5535
_ExtentX = 9763
_ExtentY = 6588
_Version = 327680
ScrollBars = 2
TextRTF = $"chatnet.frx":0442
End
Begin dsSocketLib.dsSocket dsSocket1
Height = 420
Left = 6240
TabIndex = 0
Top = 3840
Width = 420
_Version = 65543
_ExtentX = 741
_ExtentY = 741
_StockProps = 64
LocalPort = 2000
RemoteHost = ""
RemotePort = 2000
ServiceName = ""
RemoteDotAddr = ""
Linger = -1 'True
Timeout = 10
LineMode = 0 'False
EOLChar = 10
BindConnect = 0 'False
SocketType = 0
End
Begin VB.Label Label4
BackStyle = 0 'Transparent
Caption = "Nick Name:"
Height = 255
Left = 5640
TabIndex = 8
Top = 2760
Width = 975
End
Begin VB.Label Label3
BackStyle = 0 'Transparent
Caption = "Server Address:"
Height = 255
Left = 5640
TabIndex = 6
Top = 2160
Width = 1215
End
Begin VB.Label Label2
BackStyle = 0 'Transparent
Caption = "0"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 6240
TabIndex = 4
Top = 0
Width = 1215
End
Begin VB.Label Label1
BackStyle = 0 'Transparent
Caption = "Users:"
Height = 255
Left = 5640
TabIndex = 3
Top = 0
Width = 855
End
End
Attribute VB_Name = "chatnet"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'hello. this is a quick example i wrote for a multi
'user chat. this example was written in under 30
'minutes so theres no use for just "recycling" my form
'because its so easy to do on your own. please please
'please dont just rename this form and change the
'caption and call it yours. thats lame and you wont
'learn anything about programming. this example was
'meant to be used as a learning tool. i hope you like
'it and it helps you out in understanding network
'programming and just general programming a bit better.
' - Jon Cromer
' email: senate@popmail.com
' AIM: senate heh, DontTrustHAL9000
'
Private Sub Command1_Click()
On Error Resume Next 'this is a statement you should
'be starting most of your coding
'with.
'we'll be using one command button for connecting and
'disconnecting because i was too lazy to think of how
'to design this with enough space without using TAB's
'(which i use in almost every program i do)
If Command1.Caption = "Connect" Then
'checks if we can connect
If dsSocket1.LocalDotAddr = "0.0.0.0" Then
stats.Panels.Item(1).text = "Connection Error: No internet connection detected"
'display the error.
MsgBox "You don't seem to be connected to an Internet Service Provider currently or you have not been assigned a valid IP Address." & vbCrLf & "No connection will be made.", vbInformation, "Error"
'this is if the person isn't on the internet.
'if they aint, they cant chat.
Exit Sub
End If
dsSocket1.RemotePort = 2000 'set the remote port
dsSocket1.RemoteDotAddr = Text4 'set the server address
dsSocket1.Connect 'connect to the server.
stats.Panels.Item(1).text = "Connected to " & Text4
'display the connection status.
Text3.Enabled = False
Text4.Enabled = False
'disable the server address and nick name box so they
'cant be changed durring chatting.
Command1.Caption = "Disconnect"
'set the buttons caption to disconnect so we know we're